#pragma once

#include "../SGD Wrappers/SGD_Geometry.h"
#include "../SGD Wrappers/SGD_Handle.h"

#include <vector>

class Camera;
class Entity;
class Tile;
class Layer;


class TileEngine{

		//	Textures
	SGD::HTexture _grass		= SGD::INVALID_HANDLE;
	SGD::HTexture _sand			= SGD::INVALID_HANDLE;
	SGD::HTexture _blueflower	= SGD::INVALID_HANDLE;
	SGD::HTexture _collision	= SGD::INVALID_HANDLE;

		//	World data
	SGD::Size m_GridSize;
	SGD::Size m_WorldSize;
	SGD::Size m_TileSize;
	
		//	Tiles
	std::vector<Tile*> m_tiles;

	enum type {
		E_GRASS,
		E_SAND,
		E_BLUEFLOWER,
		E_IMPASSABLE,
		E_PLAYERSPAWN,
	};

	Camera* m_camera;
	Layer*	m_mapLayer;		

public:

	TileEngine();
	~TileEngine();

		//	Interface
	void Update(float elapsedtime);
	void Render();	

		//	File I/O
	void LoadMap(const char* filename);
	void SaveTestFile();

		//	Set up Layer
	void InitializeLayer();

		//	Accessors
	Camera* GetCamera()	{ return m_camera; }
	Layer*	GetMapLayer(){ return m_mapLayer; }

	SGD::Size GetWorldSize(){ return m_WorldSize; }
	std::vector<Tile*> GetTilesVec(){ return m_tiles; }

		//	Mutators
	void SetCamFocus(Entity* f);
	void SetTileSize(SGD::Size size)	{ m_TileSize = size; }
	void SetGridSize(SGD::Size size)	{ m_GridSize = size; }
	void SetWorldSize(SGD::Size size)	{ m_WorldSize = size; }
};